﻿using LostLib.Maths.Geometry3D;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Tests.LostLib
{
    
    
    /// <summary>
    ///This is a test class for Vector3DTest and is intended
    ///to contain all Vector3DTest Unit Tests
    ///</summary>
	[TestClass()]
	public class Vector3DTest
	{


		private TestContext testContextInstance;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion


		/// <summary>
		///A test for LengthSquare
		///</summary>
		[TestMethod()]
		public void LengthSquareTest()
		{
			Assert.AreEqual(new Vector3D { }.LengthSquare, 0);
		}

		/// <summary>
		///A test for Length
		///</summary>
		[TestMethod()]
		public void LengthTest()
		{
			Vector3D target = new Vector3D(); // TODO: Initialize to an appropriate value
			var actual = target.Length;
			Assert.AreEqual(actual, 0);
		}

		/// <summary>
		///A test for ToString
		///</summary>
		[TestMethod()]
		public void ToStringTest()
		{
			Assert.AreEqual("0, 0, 0", new Vector3D{}.ToString());
		}

		/// <summary>
		///A test for op_UnaryNegation
		///</summary>
		[TestMethod()]
		public void op_UnaryNegationTest()
		{
			Vector3D vector = new Vector3D { X = 1, Y = 2, Z = 3 };
			Vector3D expected = new Vector3D { X = -1, Y = -2, Z = -3 };
			var actual = -(vector);
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for op_Subtraction
		///</summary>
		[TestMethod()]
		public void op_SubtractionTest()
		{
			Vector3D left = new Vector3D { X = 1, Y = 2, Z = 3 };
			Vector3D right = new Vector3D { X = -1, Y = -2, Z = -3 };
			Vector3D expected = new Vector3D { X = 2, Y = 4, Z = 6 };
			var actual = left - right;
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for op_Multiply
		///</summary>
		[TestMethod()]
		public void op_MultiplyByFactorRightTest()
		{
			Vector3D vector = new Vector3D { X = 1, Y = 2, Z = 3 };
			double scale = 2F;
			Vector3D expected = new Vector3D { X = 2, Y = 4, Z = 6 };
			var actual = vector * scale;
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for op_Multiply
		///</summary>
		[TestMethod()]
		public void op_MultiplyByFactorLeftTest()
		{
			Vector3D vector = new Vector3D { X = 1, Y = 2, Z = 3 };
			double scale = 2F;
			Vector3D expected = new Vector3D { X = 2, Y = 4, Z = 6 };
			var actual = scale * vector;
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for op_Inequality
		///</summary>
		[TestMethod()]
		public void op_InequalityTest()
		{
			Assert.AreEqual(new Vector3D { } != new Vector3D { }, false);
			Assert.AreEqual(new Vector3D { X = 1 } != new Vector3D { Y = 1 }, true);
		}

		/// <summary>
		///A test for op_Equality
		///</summary>
		[TestMethod()]
		public void op_EqualityTest()
		{
			Assert.AreEqual(new Vector3D { } == new Vector3D { }, true);
			Assert.AreEqual(new Vector3D { } == new Vector3D { X = 1 }, false);
		}

		/// <summary>
		///A test for op_Division
		///</summary>
		[TestMethod()]
		public void op_DivisionTest()
		{
			Assert.IsTrue((new Vector3D { } / 0).IsNaN());
		}

		/// <summary>
		///A test for op_Addition
		///</summary>
		[TestMethod()]
		public void op_AdditionTest()
		{
			Vector3D left = new Vector3D { X = 1, Y = 2, Z = 3 };
			Vector3D right = new Vector3D { X = 1, Y = 2, Z = 3 };
			Vector3D expected = new Vector3D { X = 2, Y = 4, Z = 6 };
			Assert.AreEqual(expected, left + right);
		}

		/// <summary>
		///A test for GetHashCode
		///</summary>
		[TestMethod()]
		public void GetHashCodeTest()
		{
			Vector3D target = new Vector3D { X = 1, Y = 2, Z = 3 };
			var expected = (1.0).GetHashCode() ^ (2.0).GetHashCode() ^ (3.0).GetHashCode();
			Assert.AreEqual(expected, target.GetHashCode());
		}

		/// <summary>
		///A test for Equals
		///</summary>
		[TestMethod()]
		public void EqualsTest1()
		{
			Assert.AreEqual(new Vector3D { X = 1 }.Equals(new Vector3D { X = 1 }), true);
			Assert.AreEqual(new Vector3D { Y = 1 }.Equals(new Vector3D { X = 1 }), false);
		}

		/// <summary>
		///A test for Equals
		///</summary>
		[TestMethod()]
		public void EqualsTest()
		{
			Assert.AreEqual(new Vector3D { }.Equals(null), false);
			Assert.AreEqual(new Vector3D { }.Equals(new object()), false);
			Assert.AreEqual(new Vector3D { X = 1 }.Equals((object)(new Vector3D { X = 1 })), true);
			Assert.AreEqual(new Vector3D { Y = 1 }.Equals((object)(new Vector3D { X = 1 })), false);
			// Assert.Inconclusive("Verify the correctness of this test method.");
		}

		/// <summary>
		///A test for DotProduct
		///</summary>
		[TestMethod()]
		public void DotProductTest()
		{
			Vector3D target = new Vector3D {
				X = 1,
			};
			Vector3D other = new Vector3D {
				X = 1,
			};
			double expected = 1F; // TODO: Initialize to an appropriate value
			double actual;
			actual = target.DotProduct(other);
			Assert.AreEqual(expected, actual);
			//Assert.Inconclusive("Verify the correctness of this test method.");
		}

		/// <summary>
		///A test for CrossProduct
		///</summary>
		[TestMethod()]
		public void CrossProductTest()
		{
			Vector3D target = new Vector3D {
				X = 1,
			};
			Vector3D other = new Vector3D {
				Y = 1,
			};
			Vector3D expected = new Vector3D {
				Z = 1,
			};
			Vector3D actual;
			actual = target.CrossProduct(other);
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for IsInfinity
		///</summary>
		[TestMethod()]
		public void IsInfinityTest()
		{
			Assert.IsFalse(new Vector3D { }.IsInfinity());
			Assert.IsTrue(new Vector3D { X = double.NegativeInfinity }.IsInfinity());
			Assert.IsFalse(new Vector3D { X = double.NaN }.IsInfinity());
		}

		/// <summary>
		///A test for IsNaN
		///</summary>
		[TestMethod()]
		public void IsNaNTest()
		{
			Assert.IsFalse(new Vector3D { }.IsNaN());
			Assert.IsFalse(new Vector3D { X = double.NegativeInfinity }.IsNaN());
			Assert.IsTrue(new Vector3D { X = double.NaN }.IsNaN());
		}
	}
}
